this._transDispatcher = new AutorunTransientDispatcher(this);
},
- enable: function() {
+ _ensureResidentSource: function() {
+ if (this._residentSource)
+ return;
+
this._residentSource = new AutorunResidentSource(this);
+ let destroyId = this._residentSource.connect('destroy', Lang.bind(this, function() {
+ this._residentSource.disconnect(destroyId);
+ this._residentSource = null;
+ }));
+ },
+
+ enable: function() {
this._scanMounts();
this._mountAddedId = this._volumeMonitor.connect('mount-added', Lang.bind(this, this._onMountAdded));
mounts.forEach(Lang.bind(this, function (mount) {
let discoverer = new ContentTypeDiscoverer(Lang.bind (this,
function (mount, apps) {
+ this._ensureResidentSource();
this._residentSource.addMount(mount, apps);
}));
let discoverer = new ContentTypeDiscoverer(Lang.bind (this,
function (mount, apps, contentTypes) {
this._transDispatcher.addMount(mount, apps, contentTypes);
+ this._ensureResidentSource();
this._residentSource.addMount(mount, apps);
}));
_onMountRemoved: function(monitor, mount) {
this._transDispatcher.removeMount(mount);
- this._residentSource.removeMount(mount);
+ if (this._residentSource)
+ this._residentSource.removeMount(mount);
},
ejectMount: function(mount) {
this._mounts = [];
- this._notification = new AutorunResidentNotification(this._manager, this);
this._manager = manager;
+ this._notification = new AutorunResidentNotification(this._manager, this);
},
addMount: function(mount, apps) {
// now connect signals
mountButton.connect('clicked', Lang.bind(this, function(actor, event) {
- this._manager.startAppForMount(apps[0], mount);
+ startAppForMount(apps[0], mount);
}));
ejectButton.connect('clicked', Lang.bind(this, function() {